// ====================Game_BattlerBase====================

Object.defineProperties(Game_BattlerBase.prototype, {
    // 护甲，
    am: {
        get: function () {
            return this._armor;
        },
        configurable: true
    }
})

/* 是否能够支付技能消耗 */
SDS_CARD_COPY.Game_BattlerBase_canPaySkillCost = Game_BattlerBase.prototype.canPaySkillCost;
Game_BattlerBase.prototype.canPaySkillCost = function (skill) {
    if (CardGameManager.isCardGame()) {
        return true;
    } else {
        return SDS_CARD_COPY.Game_BattlerBase_canPaySkillCost.call(this, skill);
    }
};

/**
 * 获取护甲
 */
Game_BattlerBase.prototype.gainArmor = function (value) {
    this._armor = Math.max((this._armor + value), 0);
}

SDS_CARD_COPY.Game_BattlerBase_initMembers = Game_BattlerBase.prototype.initMembers;
Game_BattlerBase.prototype.initMembers = function () {
    SDS_CARD_COPY.Game_BattlerBase_initMembers.call(this);
    this._armor = 0;
}

/**
 * 清除护甲
 */
Game_BattlerBase.prototype.clearArmor = function () {
    this._armor = 0;
}

SDS_CARD_COPY.Game_Battler_gainHp = Game_Battler.prototype.gainHp;
Game_Battler.prototype.gainHp = function (value) {
    const armor = this.am;
    if (armor > 0 && value < 0) {
        if (armor >= -value) {
            this.gainArmor(value);
            return;
        } else {
            this.clearArmor();
            value += armor;
            SDS_CARD_COPY.Game_Battler_gainHp.call(this, value);
        }
    } else {
        SDS_CARD_COPY.Game_Battler_gainHp.call(this, value);
    }
};

Game_Battler.prototype.performanceCardActionResults = function () {
    if (this.result().hpAffected) {
        if (this.result().hpDamage > 0 && !this.result().drain) {
            this.performDamage();
        }
        if (this.result().hpDamage < 0) {
            this.performRecovery();
        }
    }
    this.startDamagePopup();
    // this.clearResult();
    if (this.isDead()) {
        this.performCollapse();
    }
}

/**
 * 获取角色的职业卡
 */
Game_Actor.prototype.allClassCard = function () {
    const classData = this.currentClass();
    const cards = classData.cards;
    return cards || [];
}